<?php
/**
 * KePHP, Keep PHP easy!
 */

namespace CSService\Model\Command;

use Ke\Adm\Model;

/**
 * Class Command
 * tableName command
 *
 * // class properties
 * @property int    $id           id
 * @property string $name         命令名称
 * @property string $show_name    显示名称
 * @property string $command      执行命令
 * @property int    $group_id     命令分组
 * @property int    $position     排序
 * @property int    $check_dir    目录检查
 * @property int    $user_confirm 用户确认
 * @property int    $is_alone     是否独占
 * @property int    $is_log       是否日志
 * // class properties
 */
class Command extends Model
{

	protected static $pk = 'id';

	protected static $pkAutoInc = true;

	protected static $columns = [
		'name'         => ['edit' => 'text', 'unique' => 1, 'require' => 1,],
		'show_name'    => ['edit' => 'text', 'require' => 1],
		'command'      => ['edit' => 'text', 'require' => 1,],
		'group_id'     => [
			'edit' => 'radio', 'options' => [
				0 => '默认', 1 => '分组1', 2 => '分组2', 3 => '分组3', 4 => '分组4', 5 => '分组5',
			],
		],
		'position'     => ['edit' => 'number'],
		'is_alone'     => [
			'edit' => 'radio', 'options' => [
				0 => '非独占', 1 => '本命令独占<small>（该命令未完成不可重复执行）</small>', 2 => '全独占<small>（该命令未完成会禁止其他命令运行）</small>',
			],
		],
		'check_dir'    => ['edit' => 'radio', 'options' => [0 => '不检查', 1 => '检查存在', 2 => '检查不存在']],
		'user_confirm' => ['edit' => 'radio', 'options' => [0 => '不用确认', 1 => '需要确认']],
		'is_log'       => ['edit' => 'radio', 'options' => [0 => '不记录', 1 => '记录']],
	];

	public static function dbColumns()
	{
		// database columns
		// generated as 2016-02-01 22:52:19
		return [
			'id'           => ['int' => 1, 'pk' => 1, 'autoInc' => 1],
			'name'         => ['label' => '命令名称', 'max' => 32],
			'show_name'    => ['label' => '显示名称', 'max' => 32],
			'command'      => ['label' => '执行命令', 'max' => 128],
			'group_id'     => ['label' => '命令分组', 'int' => 1, 'default' => 0],
			'position'     => ['label' => '排序', 'int' => 1, 'default' => 1000],
			'check_dir'    => ['label' => '目录检查', 'int' => 1, 'default' => 0],
			'user_confirm' => ['label' => '用户确认', 'int' => 1, 'default' => 0],
			'is_alone'     => ['label' => '是否独占', 'int' => 1, 'default' => 0],
			'is_log'       => ['label' => '是否日志', 'int' => 1, 'default' => 1],
		];
		// database columns
	}

}
